home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / var / lib / dpkg / info / findutils.preinst < prev    next >
Text File  |  2009-06-15  |  2KB  |  75 lines

  1. #!/bin/sh
  2.  
  3. set -e
  4.  
  5. # Inspired from
  6. # http://wiki.debian.org/DpkgConffileHandling
  7. # Move contents from dpkg-conffile to optional (not dpkg-managed) file
  8. mv_with_comment_conffile() {
  9.     PKGNAME="$1"
  10.     CONFFILE="$2"
  11.     OPTIONALCONFIG="$3"
  12.  
  13.     if [ -e "$CONFFILE" ]; then
  14.         md5sum="`md5sum \"$CONFFILE\" | sed -e \"s/ .*//\"`"
  15.         old_md5sum="`dpkg-query -W -f='${Conffiles}' $PKGNAME | sed -n -e \"\\\\' $CONFFILE'{s/ obsolete$//;s/.* //p}\"`"
  16.         if [ "$md5sum" = "$old_md5sum" ]; then
  17.             echo "Removing obsolete conffile $CONFFILE ..."
  18.             rm -f "$CONFFILE"
  19.         else
  20.             if [ -e "$OPTIONALCONFIG" ] ; then
  21.             # $CONFFILE has been removed, but user has already generated 
  22.             # non-dpkgconffile OPTIONALCONFIG
  23.                 echo "Obsolete conffile $CONFFILE has been modified by you."
  24.                 echo "Saving as $CONFFILE.dpkg-bak ..."
  25.                 mv "$CONFFILE" "$CONFFILE".dpkg-bak
  26.             else
  27.                 echo generating "$OPTIONALCONFIG" from user modified "$CONFFILE"
  28.                 { echo "# Generated from $CONFFILE when upgrading $PKGNAME" 
  29.                     cat "$CONFFILE" ; } \
  30.                     > "$OPTIONALCONFIG"
  31.                 chmod --reference="$CONFFILE" "$OPTIONALCONFIG"
  32.                 echo "Saving $CONFFILE as $CONFFILE.dpkg-bak ..."
  33.                 mv "$CONFFILE" "$CONFFILE".dpkg-bak
  34.             fi
  35.         fi
  36.     fi
  37. }
  38.  
  39.  
  40. # Remove a no-longer used conffile
  41. # http://wiki.debian.org/DpkgConffileHandling
  42. rm_conffile() {
  43.   PKGNAME="$1"
  44.   CONFFILE="$2"
  45.  
  46.   if [ -e "$CONFFILE" ]; then
  47.     md5sum="`md5sum \"$CONFFILE\" | sed -e \"s/ .*//\"`"
  48.     old_md5sum="`dpkg-query -W -f='${Conffiles}' $PKGNAME | sed -n -e \"\\\\' $CONFFILE'{s/ obsolete$//;s/.* //p}\"`"
  49.     if [ "$md5sum" != "$old_md5sum" ]; then
  50.       echo "Obsolete conffile $CONFFILE has been modified by you."
  51.       echo "Saving as $CONFFILE.dpkg-bak ..."
  52.       mv -f "$CONFFILE" "$CONFFILE".dpkg-bak
  53.     else
  54.       echo "Removing obsolete conffile $CONFFILE ..."
  55.       rm -f "$CONFFILE"
  56.     fi
  57.   fi
  58. }
  59.  
  60. case "$1" in
  61.   install|upgrade)
  62.     if dpkg --compare-versions "$2" lt-nl "4.2.31-2"; then
  63.     # delete if unchanged, rename otherwise.
  64.       mv_with_comment_conffile findutils "/etc/updatedb.conf" \
  65.         /etc/updatedb.findutils.cron.local
  66.       rm_conffile findutils "/etc/cron.daily/find"
  67.     fi
  68.   ;;
  69. esac
  70.  
  71.  
  72.  
  73.  
  74. # vim:tabstop=2:expandtab:shiftwidth=2
  75.